home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / gas / doc / gasp.info < prev    next >
Encoding:
GNU Info File  |  1996-07-15  |  39.0 KB  |  1,088 lines

  1. This is Info file gasp.info, produced by Makeinfo-1.55 from the input
  2. file ./gasp.texi.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * gasp: (gasp).                     The GNU Assembler Preprocessor
  6. END-INFO-DIR-ENTRY
  7.  
  8.    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided also
  16. that the entire resulting derived work is distributed under the terms
  17. of a permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions.
  22.  
  23. 
  24. File: gasp.info,  Node: Top,  Next: Overview,  Prev: (DIR),  Up: (DIR)
  25.  
  26. GASP
  27. ****
  28.  
  29.    GASP is a preprocessor for assembly programs.
  30.  
  31.    This file describes version 1 of GASP.
  32.  
  33.    Steve Chamberlain wrote GASP; Roland Pesch wrote this manual.
  34.  
  35. * Menu:
  36.  
  37. * Overview::                    What is GASP?
  38. * Invoking GASP::               Command line options.
  39. * Commands::                    Preprocessor commands.
  40. * Index::                       Index.
  41.  
  42. 
  43. File: gasp.info,  Node: Overview,  Next: Invoking GASP,  Prev: Top,  Up: Top
  44.  
  45. What is GASP?
  46. *************
  47.  
  48.    The primary purpose of the GNU assembler is to assemble the output of
  49. other programs--notably compilers.  When you have to hand-code
  50. specialized routines in assembly, that means the GNU assembler is an
  51. unfriendly processor: it has no directives for macros, conditionals, or
  52. many other conveniences that you might expect.
  53.  
  54.    In some cases you can simply use the C preprocessor, or a generalized
  55. preprocessor like M4; but this can be awkward, since none of these
  56. things are designed with assembly in mind.
  57.  
  58.    GASP fills this need.  It is expressly designed to provide the
  59. facilities you need with hand-coded assembly code.  Implementing it as a
  60. preprocessor, rather than part of the assembler, allows the maximum
  61. flexibility: you can use it with hand-coded assembly, without paying a
  62. penalty of added complexity in the assembler you use for compiler
  63. output.
  64.  
  65.    Here is a small example to give the flavor of GASP.  This input to
  66. GASP
  67.  
  68.              .MACRO  saveregs from=8 to=14
  69.      count   .ASSIGNA \from
  70.              ! save r\from..r\to
  71.              .AWHILE  \&count LE \to
  72.              mov     r\&count,@-sp
  73.      count   .ASSIGNA  \&count + 1
  74.              .AENDW
  75.              .ENDM
  76.      
  77.              saveregs from=12
  78.      
  79.      bar:    mov     #H'dead+10,r0
  80.      foo     .SDATAC "hello"<10>
  81.              .END
  82.  
  83. generates this assembly program:
  84.  
  85.              ! save r12..r14
  86.              mov     r12,@-sp
  87.              mov     r13,@-sp
  88.              mov     r14,@-sp
  89.      
  90.      bar:    mov     #57005+10,r0
  91.      foo:    .byte   6,104,101,108,108,111,10
  92.  
  93. 
  94. File: gasp.info,  Node: Invoking GASP,  Next: Commands,  Prev: Overview,  Up: Top
  95.  
  96. Command Line Options
  97. ********************
  98.  
  99.    The simplest way to use GASP is to run it as a filter and assemble
  100. its output.  In Unix and its ilk, you can do this, for example:
  101.  
  102.      $ gasp prog.asm | as -o prog.o
  103.  
  104.    Naturally, there are also a few command-line options to allow you to
  105. request variations on this basic theme.  Here is the full set of
  106. possibilities for the GASP command line.
  107.  
  108.      gasp  [ -a | --alternate ]
  109.            [ -c CHAR | --commentchar CHAR ]
  110.            [ -d | --debug ]  [ -h | --help ] [ -M | --mri ]
  111.            [ -o OUTFILE | --output OUTFILE ]
  112.            [ -p | --print ]  [ -s | --copysource ]
  113.            [ -u | --unreasonable ]  [ -v | --version ]
  114.            INFILE ...
  115.  
  116. `INFILE ...'
  117.      The input file names.  You must specify at least one input file;
  118.      if you specify more, GASP preprocesses them all, concatenating the
  119.      output in the order you list the INFILE arguments.
  120.  
  121.      Mark the end of each input file with the preprocessor command
  122.      `.END'.  *Note Miscellaneous commands: Other Commands.
  123.  
  124. `-a'
  125. `--alternate'
  126.      Use alternative macro syntax.  *Note Alternate macro syntax:
  127.      Alternate, for a discussion of how this syntax differs from the
  128.      default GASP syntax.
  129.  
  130. `-c 'CHAR''
  131. `--commentchar 'CHAR''
  132.      Use CHAR as the comment character.  The default comment character
  133.      is `!'.  For example, to use a semicolon as the comment character,
  134.      specify `-c ';'' on the GASP command line.  Since assembler
  135.      command characters often have special significance to command
  136.      shells, it is a good idea to quote or escape CHAR when you specify
  137.      a comment character.
  138.  
  139.      For the sake of simplicity, all examples in this manual use the
  140.      default comment character `!'.
  141.  
  142. `-d'
  143. `--debug'
  144.      Show debugging statistics.  In this version of GASP, this option
  145.      produces statistics about the string buffers that GASP allocates
  146.      internally.  For each defined buffersize S, GASP shows the number
  147.      of strings N that it allocated, with a line like this:
  148.  
  149.           strings size S : N
  150.  
  151.      GASP displays these statistics on the standard error stream, when
  152.      done preprocessing.
  153.  
  154. `-h'
  155. `--help'
  156.      Display a summary of the GASP command line options.
  157.  
  158. `-M'
  159. `--mri'
  160.      Use MRI compatibility mode.  Using this option causes GASP to
  161.      accept the syntax and pseudo-ops used by the Microtec Research
  162.      `ASM68K' assembler.
  163.  
  164. `-o OUTFILE'
  165. `--output OUTFILE'
  166.      Write the output in a file called OUTFILE.  If you do not use the
  167.      `-o' option, GASP writes its output on the standard output stream.
  168.  
  169. `-p'
  170. `--print'
  171.      Print line numbers.  GASP obeys this option *only* if you also
  172.      specify `-s' to copy source lines to its output.  With `-s -p',
  173.      GASP displays the line number of each source line copied
  174.      (immediately after the comment character at the beginning of the
  175.      line).
  176.  
  177. `-s'
  178. `--copysource'
  179.      Copy the source lines to the output file.  Use this option to see
  180.      the effect of each preprocessor line on the GASP output.  GASP
  181.      places a comment character (`!' by default) at the beginning of
  182.      each source line it copies, so that you can use this option and
  183.      still assemble the result.
  184.  
  185. `-u'
  186. `--unreasonable'
  187.      Bypass "unreasonable expansion" limit.  Since you can define GASP
  188.      macros inside other macro definitions, the preprocessor normally
  189.      includes a sanity check.  If your program requires more than 1,000
  190.      nested expansions, GASP normally exits with an error message.  Use
  191.      this option to turn off this check, allowing unlimited nested
  192.      expansions.
  193.  
  194. `-v'
  195. `--version'
  196.      Display the GASP version number.
  197.  
  198. 
  199. File: gasp.info,  Node: Commands,  Next: Index,  Prev: Invoking GASP,  Up: Top
  200.  
  201. Preprocessor Commands
  202. *********************
  203.  
  204.    GASP commands have a straightforward syntax that fits in well with
  205. assembly conventions.  In general, a command extends for a line, and may
  206. have up to three fields: an optional label, the command itself, and
  207. optional arguments to the command.  You can write commands in upper or
  208. lower case, though this manual shows them in upper case.  *Note Details
  209. of the GASP syntax: Syntax Details, for more information.
  210.  
  211. * Menu:
  212.  
  213. * Conditionals::
  214. * Loops::
  215. * Variables::
  216. * Macros::
  217. * Data::
  218. * Listings::
  219. * Other Commands::
  220. * Syntax Details::
  221. * Alternate::
  222.  
  223. 
  224. File: gasp.info,  Node: Conditionals,  Next: Loops,  Up: Commands
  225.  
  226. Conditional assembly
  227. ====================
  228.  
  229.    The conditional-assembly directives allow you to include or exclude
  230. portions of an assembly depending on how a pair of expressions, or a
  231. pair of strings, compare.
  232.  
  233.    The overall structure of conditionals is familiar from many other
  234. contexts.  `.AIF' marks the start of a conditional, and precedes
  235. assembly for the case when the condition is true.   An optional
  236. `.AELSE' precedes assembly for the converse case, and an `.AENDI' marks
  237. the end of the condition.
  238.  
  239.    You may nest conditionals up to a depth of 100; GASP rejects nesting
  240. beyond that, because it may indicate a bug in your macro structure.
  241.  
  242.    Conditionals are primarily useful inside macro definitions, where you
  243. often need different effects depending on argument values.  *Note
  244. Defining your own directives: Macros, for details about defining macros.
  245.  
  246. `.AIF EXPRA CMP EXPRB'
  247. `.AIF "STRA" CMP "STRB"'
  248.      The governing condition goes on the same line as the `.AIF'
  249.      preprocessor command.  You may compare either two strings, or two
  250.      expressions.
  251.  
  252.      When you compare strings, only two conditional CMP comparison
  253.      operators are available: `EQ' (true if STRA and STRB are
  254.      identical), and `NE' (the opposite).
  255.  
  256.      When you compare two expressions, *both expressions must be
  257.      absolute* (*note Arithmetic expressions in GASP: Expressions.).
  258.      You can use these CMP comparison operators with expressions:
  259.  
  260.     `EQ'
  261.           Are EXPRA and EXPRB equal?  (For strings, are STRA and STRB
  262.           identical?)
  263.  
  264.     `NE'
  265.           Are EXPRA and EXPRB different?  (For strings, are STRA and
  266.           STRB different?
  267.  
  268.     `LT'
  269.           Is EXPRA less than EXPRB?  (Not allowed for strings.)
  270.  
  271.     `LE'
  272.           Is EXPRA less than or equal to EXPRB?  (Not allowed for
  273.           strings.)
  274.  
  275.     `GT'
  276.           Is EXPRA greater than EXPRB?  (Not allowed for strings.)
  277.  
  278.     `GE'
  279.           Is EXPRA greater than or equal to EXPRB?  (Not allowed for
  280.           strings.)
  281.  
  282. `.AELSE'
  283.      Marks the start of assembly code to be included if the condition
  284.      fails.  Optional, and only allowed within a conditional (between
  285.      `.AIF' and `.AENDI').
  286.  
  287. `.AENDI'
  288.      Marks the end of a conditional assembly.
  289.  
  290. 
  291. File: gasp.info,  Node: Loops,  Next: Variables,  Prev: Conditionals,  Up: Commands
  292.  
  293. Repetitive sections of assembly
  294. ===============================
  295.  
  296.    Two preprocessor directives allow you to repeatedly issue copies of
  297. the same block of assembly code.
  298.  
  299. `.AREPEAT AEXP'
  300. `.AENDR'
  301.      If you simply need to repeat the same block of assembly over and
  302.      over a fixed number of times, sandwich one instance of the
  303.      repeated block between `.AREPEAT' and `.AENDR'.  Specify the
  304.      number of copies as AEXP (which must be an absolute expression).
  305.      For example, this repeats two assembly statements three times in
  306.      succession:
  307.  
  308.                   .AREPEAT        3
  309.                   rotcl   r2
  310.                   div1    r0,r1
  311.                   .AENDR
  312.  
  313. `.AWHILE EXPRA CMP EXPRB'
  314. `.AENDW'
  315. `.AWHILE STRA CMP STRB'
  316. `.AENDW'
  317.      To repeat a block of assembly depending on a conditional test,
  318.      rather than repeating it for a specific number of times, use
  319.      `.AWHILE'.  `.AENDW' marks the end of the repeated block.  The
  320.      conditional comparison works exactly the same way as for `.AIF',
  321.      with the same comparison operators (*note Conditional assembly:
  322.      Conditionals.).
  323.  
  324.      Since the terms of the comparison must be absolute expression,
  325.      `.AWHILE' is primarily useful within macros.  *Note Defining your
  326.      own directives: Macros.
  327.  
  328.    You can use the `.EXITM' preprocessor directive to break out of
  329. loops early (as well as to break out of macros).  *Note Defining your
  330. own directives: Macros.
  331.  
  332. 
  333. File: gasp.info,  Node: Variables,  Next: Macros,  Prev: Loops,  Up: Commands
  334.  
  335. Preprocessor variables
  336. ======================
  337.  
  338.    You can use variables in GASP to represent strings, registers, or
  339. the results of expressions.
  340.  
  341.    You must distinguish two kinds of variables:
  342.   1. Variables defined with `.EQU' or `.ASSIGN'.  To evaluate this kind
  343.      of variable in your assembly output, simply mention its name.  For
  344.      example, these two lines define and use a variable `eg':
  345.  
  346.           eg     .EQU   FLIP-64
  347.                  ...
  348.                  mov.l  eg,r0
  349.  
  350.      *Do not use* this kind of variable in conditional expressions or
  351.      while loops; GASP only evaluates these variables when writing
  352.      assembly output.
  353.  
  354.   2. Variables for use during preprocessing.  You can define these with
  355.      `.ASSIGNC' or `.ASSIGNA'.  To evaluate this kind of variable,
  356.      write `\&' before the variable name; for example,
  357.  
  358.           opcit  .ASSIGNA  47
  359.                  ...
  360.                  .AWHILE  \&opcit GT 0
  361.                  ...
  362.                  .AENDW
  363.  
  364.      GASP treats macro arguments almost the same way, but to evaluate
  365.      them you use the prefix `\' rather than `\&'.  *Note Defining your
  366.      own directives: Macros.
  367.  
  368. `PVAR .EQU EXPR'
  369.      Assign preprocessor variable PVAR the value of the expression
  370.      EXPR.  There are no restrictions on redefinition; use `.EQU' with
  371.      the same PVAR as often as you find it convenient.
  372.  
  373. `PVAR .ASSIGN EXPR'
  374.      Almost the same as `.EQU', save that you may not redefine PVAR
  375.      using `.ASSIGN' once it has a value.
  376.  
  377. `PVAR .ASSIGNA AEXPR'
  378.      Define a variable with a numeric value, for use during
  379.      preprocessing.  AEXPR must be an absolute expression.  You can
  380.      redefine variables with `.ASSIGNA' at any time.
  381.  
  382. `PVAR .ASSIGNC "STR"'
  383.      Define a variable with a string value, for use during
  384.      preprocessing.  You can redefine variables with `.ASSIGNC' at any
  385.      time.
  386.  
  387. `PVAR .REG (REGISTER)'
  388.      Use `.REG' to define a variable that represents a register.  In
  389.      particular, REGISTER is *not evaluated* as an expression.  You may
  390.      use `.REG' at will to redefine register variables.
  391.  
  392.    All these directives accept the variable name in the "label"
  393. position, that is at the left margin.  You may specify a colon after
  394. the variable name if you wish; the first example above could have
  395. started `eg:' with the same effect.
  396.  
  397. 
  398. File: gasp.info,  Node: Macros,  Next: Data,  Prev: Variables,  Up: Commands
  399.  
  400. Defining your own directives
  401. ============================
  402.  
  403.    The commands `.MACRO' and `.ENDM' allow you to define macros that
  404. generate assembly output.  You can use these macros with a syntax
  405. similar to built-in GASP or assembler directives.  For example, this
  406. definition specifies a macro `SUM' that adds together a range of
  407. consecutive registers:
  408.  
  409.              .MACRO  SUM FROM=0, TO=9
  410.              ! \FROM \TO
  411.              mov     r\FROM,r10
  412.      COUNT   .ASSIGNA        \FROM+1
  413.              .AWHILE \&COUNT LE \TO
  414.              add     r\&COUNT,r10
  415.      COUNT   .ASSIGNA        \&COUNT+1
  416.              .AENDW
  417.              .ENDM
  418.  
  419. With that definition, `SUM 0,5' generates this assembly output:
  420.  
  421.              ! 0 5
  422.              mov     r0,r10
  423.              add     r1,r10
  424.              add     r2,r10
  425.              add     r3,r10
  426.              add     r4,r10
  427.              add     r5,r10
  428.  
  429. `.MACRO MACNAME'
  430. `.MACRO MACNAME MACARGS ...'
  431.      Begin the definition of a macro called MACNAME.  If your macro
  432.      definition requires arguments, specify their names after the macro
  433.      name, separated by commas or spaces.  You can supply a default
  434.      value for any macro argument by following the name with `=DEFLT'.
  435.      For example, these are all valid `.MACRO' statements:
  436.  
  437.     `.MACRO COMM'
  438.           Begin the definition of a macro called `COMM', which takes no
  439.           arguments.
  440.  
  441.     `.MACRO PLUS1 P, P1'
  442.     `.MACRO PLUS1 P P1'
  443.           Either statement begins the definition of a macro called
  444.           `PLUS1', which takes two arguments; within the macro
  445.           definition, write `\P' or `\P1' to evaluate the arguments.
  446.  
  447.     `.MACRO RESERVE_STR P1=0 P2'
  448.           Begin the definition of a macro called `RESERVE_STR', with two
  449.           arguments.  The first argument has a default value, but not
  450.           the second.  After the definition is complete, you can call
  451.           the macro either as `RESERVE_STR A,B' (with `\P1' evaluating
  452.           to A and `\P2' evaluating to B), or as `RESERVE_STR ,B' (with
  453.           `\P1' evaluating as the default, in this case `0', and `\P2'
  454.           evaluating to B).
  455.  
  456.      When you call a macro, you can specify the argument values either
  457.      by position, or by keyword.  For example, `SUM 9,17' is equivalent
  458.      to `SUM TO=17, FROM=9'.  Macro arguments are preprocessor variables
  459.      similar to the variables you define with `.ASSIGNA' or `.ASSIGNC';
  460.      in particular, you can use them in conditionals or for loop
  461.      control.  (The only difference is the prefix you write to evaluate
  462.      the variable: for a macro argument, write `\ARGNAME', but for a
  463.      preprocessor variable, write `\&VARNAME'.)
  464.  
  465. `NAME .MACRO'
  466. `NAME .MACRO ( MACARGS ... )'
  467.      An alternative form of introducing a macro definition: specify the
  468.      macro name in the label position, and the arguments (if any)
  469.      between parentheses after the name.  Defaulting rules and usage
  470.      work the same way as for the other macro definition syntax.
  471.  
  472. `.ENDM'
  473.      Mark the end of a macro definition.
  474.  
  475. `.EXITM'
  476.      Exit early from the current macro definition, `.AREPEAT' loop, or
  477.      `.AWHILE' loop.
  478.  
  479. `\@'
  480.      GASP maintains a counter of how many macros it has executed in
  481.      this pseudo-variable; you can copy that number to your output with
  482.      `\@', but *only within a macro definition*.
  483.  
  484. `LOCAL NAME [ , ... ]'
  485.      *Warning: `LOCAL' is only available if you select "alternate macro
  486.      syntax" with `-a' or `--alternate'.*  *Note Alternate macro
  487.      syntax: Alternate.
  488.  
  489.      Generate a string replacement for each of the NAME arguments, and
  490.      replace any instances of NAME in each macro expansion.  The
  491.      replacement string is unique in the assembly, and different for
  492.      each separate macro expansion.  `LOCAL' allows you to write macros
  493.      that define symbols, without fear of conflict between separate
  494.      macro expansions.
  495.  
  496. 
  497. File: gasp.info,  Node: Data,  Next: Listings,  Prev: Macros,  Up: Commands
  498.  
  499. Data output
  500. ===========
  501.  
  502.    In assembly code, you often need to specify working areas of memory;
  503. depending on the application, you may want to initialize such memory or
  504. not.  GASP provides preprocessor directives to help you avoid
  505. repetitive coding for both purposes.
  506.  
  507.    You can use labels as usual to mark the data areas.
  508.  
  509. * Menu:
  510.  
  511. * Initialized::
  512. * Uninitialized::
  513.  
  514. 
  515. File: gasp.info,  Node: Initialized,  Next: Uninitialized,  Up: Data
  516.  
  517. Initialized data
  518. ----------------
  519.  
  520.    These are the GASP directives for initialized data, and the standard
  521. GNU assembler directives they expand to:
  522.  
  523. `.DATA EXPR, EXPR, ...'
  524. `.DATA.B EXPR, EXPR, ...'
  525. `.DATA.W EXPR, EXPR, ...'
  526. `.DATA.L EXPR, EXPR, ...'
  527.      Evaluate arithmetic expressions EXPR, and emit the corresponding
  528.      `as' directive (labelled with LAB).  The unqualified `.DATA' emits
  529.      `.long'; `.DATA.B' emits `.byte'; `.DATA.W' emits `.short'; and
  530.      `.DATA.L' emits `.long'.
  531.  
  532.      For example, `foo .DATA 1,2,3' emits `foo: .long 1,2,3'.
  533.  
  534. `.DATAB REPEAT, EXPR'
  535. `.DATAB.B REPEAT, EXPR'
  536. `.DATAB.W REPEAT, EXPR'
  537. `.DATAB.L REPEAT, EXPR'
  538.      Make `as' emit REPEAT copies of the value of the expression EXPR
  539.      (using the `as' directive `.fill').  `.DATAB.B' repeats one-byte
  540.      values; `.DATAB.W' repeats two-byte values; and `.DATAB.L' repeats
  541.      four-byte values.  `.DATAB' without a suffix repeats four-byte
  542.      values, just like `.DATAB.L'.
  543.  
  544.      REPEAT must be an absolute expression with a positive value.
  545.  
  546. `.SDATA "STR" ...'
  547.      String data.  Emits a concatenation of bytes, precisely as you
  548.      specify them (in particular, *nothing is added to mark the end* of
  549.      the string).  *Note String and numeric constants: Constants, for
  550.      details about how to write strings.  `.SDATA' concatenates multiple
  551.      arguments, making it easy to switch between string
  552.      representations.  You can use commas to separate the individual
  553.      arguments for clarity, if you choose.
  554.  
  555. `.SDATAB REPEAT, "STR" ...'
  556.      Repeated string data.  The first argument specifies how many
  557.      copies of the string to emit; the remaining arguments specify the
  558.      string, in the same way as the arguments to `.SDATA'.
  559.  
  560. `.SDATAZ "STR" ...'
  561.      Zero-terminated string data.  Just like `.SDATA', except that
  562.      `.SDATAZ' writes a zero byte at the end of the string.
  563.  
  564. `.SDATAC "STR" ...'
  565.      Count-prefixed string data.  Just like `.SDATA', except that GASP
  566.      precedes the string with a leading one-byte count.  For example,
  567.      `.SDATAC "HI"' generates `.byte 2,72,73'.  Since the count field
  568.      is only one byte, you can only use `.SDATAC' for strings less than
  569.      256 bytes in length.
  570.  
  571. 
  572. File: gasp.info,  Node: Uninitialized,  Prev: Initialized,  Up: Data
  573.  
  574. Uninitialized data
  575. ------------------
  576.  
  577.    Use the `.RES', `.SRES', `.SRESC', and `.SRESZ' directives to
  578. reserve memory and leave it uninitialized.  GASP resolves these
  579. directives to appropriate calls of the GNU `as' `.space' directive.
  580.  
  581. `.RES COUNT'
  582. `.RES.B COUNT'
  583. `.RES.W COUNT'
  584. `.RES.L COUNT'
  585.      Reserve room for COUNT uninitialized elements of data.  The suffix
  586.      specifies the size of each element: `.RES.B' reserves COUNT bytes,
  587.      `.RES.W' reserves COUNT pairs of bytes, and `.RES.L' reserves
  588.      COUNT quartets.  `.RES' without a suffix is equivalent to `.RES.L'.
  589.  
  590. `.SRES COUNT'
  591. `.SRES.B COUNT'
  592. `.SRES.W COUNT'
  593. `.SRES.L COUNT'
  594.      `.SRES' is a synonym for `.RES'.
  595.  
  596. `.SRESC COUNT'
  597. `.SRESC.B COUNT'
  598. `.SRESC.W COUNT'
  599. `.SRESC.L COUNT'
  600.      Like `.SRES', but reserves space for `COUNT+1' elements.
  601.  
  602. `.SRESZ COUNT'
  603. `.SRESZ.B COUNT'
  604. `.SRESZ.W COUNT'
  605. `.SRESZ.L COUNT'
  606.      Like `.SRES', but reserves space for `COUNT+1' elements.
  607.  
  608. 
  609. File: gasp.info,  Node: Listings,  Next: Other Commands,  Prev: Data,  Up: Commands
  610.  
  611. Assembly listing control
  612. ========================
  613.  
  614.    The GASP listing-control directives correspond to related GNU `as'
  615. directives.
  616.  
  617. `.PRINT LIST'
  618. `.PRINT NOLIST'
  619.      Print control.  This directive emits the GNU `as' directive
  620.      `.list' or `.nolist', according to its argument.  *Note `.list':
  621.      (as.info)List, for details on how these directives interact.
  622.  
  623. `.FORM LIN=LN'
  624. `.FORM COL=COLS'
  625. `.FORM LIN=LN COL=COLS'
  626.      Specify the page size for assembly listings: LN represents the
  627.      number of lines, and COLS the number of columns.  You may specify
  628.      either page dimension independently, or both together.  If you do
  629.      not specify the number of lines, GASP assumes 60 lines; if you do
  630.      not specify the number of columns, GASP assumes 132 columns.  (Any
  631.      values you may have specified in previous instances of `.FORM' do
  632.      *not* carry over as defaults.)  Emits the `.psize' assembler
  633.      directive.
  634.  
  635. `.HEADING STRING'
  636.      Specify STRING as the title of your assembly listings.  Emits
  637.      `.title "STRING"'.
  638.  
  639. `.PAGE'
  640.      Force a new page in assembly listings.  Emits `.eject'.
  641.  
  642. 
  643. File: gasp.info,  Node: Other Commands,  Next: Syntax Details,  Prev: Listings,  Up: Commands
  644.  
  645. Miscellaneous commands
  646. ======================
  647.  
  648. `.ALTERNATE'
  649.      Use the alternate macro syntax henceforth in the assembly.  *Note
  650.      Alternate macro syntax: Alternate.
  651.  
  652. `.ORG'
  653.      This command is recognized, but not yet implemented.  GASP
  654.      generates an error message for programs that use `.ORG'.
  655.  
  656. `.RADIX S'
  657.      GASP understands numbers in any of base two, eight, ten, or
  658.      sixteen.  You can encode the base explicitly in any numeric
  659.      constant (*note String and numeric constants: Constants.).  If you
  660.      write numbers without an explicit indication of the base, the most
  661.      recent `.RADIX S' command determines how they are interpreted.  S
  662.      is a single letter, one of the following:
  663.  
  664.     `.RADIX B'
  665.           Base 2.
  666.  
  667.     `.RADIX Q'
  668.           Base 8.
  669.  
  670.     `.RADIX D'
  671.           Base 10.  This is the original default radix.
  672.  
  673.     `.RADIX H'
  674.           Base 16.
  675.  
  676.      You may specify the argument S in lower case (any of `bqdh') with
  677.      the same effects.
  678.  
  679. `.EXPORT NAME'
  680. `.GLOBAL NAME'
  681.      Declare NAME global (emits `.global NAME').  The two directives
  682.      are synonymous.
  683.  
  684. `.PROGRAM'
  685.      No effect: GASP accepts this directive, and silently ignores it.
  686.  
  687. `.END'
  688.      Mark end of each preprocessor file.  GASP issues a warning if it
  689.      reaches end of file without seeing this command.
  690.  
  691. `.INCLUDE "STR"'
  692.      Preprocess the file named by STR, as if its contents appeared
  693.      where the `.INCLUDE' directive does.  GASP imposes a maximum limit
  694.      of 30 stacked include files, as a sanity check.
  695.  
  696. `.ALIGN SIZE'
  697.      Evaluate the absolute expression SIZE, and emit the assembly
  698.      instruction `.align SIZE' using the result.
  699.  
  700. 
  701. File: gasp.info,  Node: Syntax Details,  Next: Alternate,  Prev: Other Commands,  Up: Commands
  702.  
  703. Details of the GASP syntax
  704. ==========================
  705.  
  706.    Since GASP is meant to work with assembly code, its statement syntax
  707. has no surprises for the assembly programmer.
  708.  
  709.    *Whitespace* (blanks or tabs; *not* newline) is partially
  710. significant, in that it delimits up to three fields in a line.  The
  711. amount of whitespace does not matter; you may line up fields in separate
  712. lines if you wish, but GASP does not require that.
  713.  
  714.    The *first field*, an optional "label", must be flush left in a line
  715. (with no leading whitespace) if it appears at all.  You may use a colon
  716. after the label if you wish; GASP neither requires the colon nor
  717. objects to it (but will not include it as part of the label name).
  718.  
  719.    The *second field*, which must appear after some whitespace,
  720. contains a GASP or assembly "directive".
  721.  
  722.    Any *further fields* on a line are "arguments" to the directive; you
  723. can separate them from one another using either commas or whitespace.
  724.  
  725. * Menu:
  726.  
  727. * Markers::
  728. * Constants::
  729. * Symbols::
  730. * Expressions::
  731. * String Builtins::
  732.  
  733. 
  734. File: gasp.info,  Node: Markers,  Next: Constants,  Up: Syntax Details
  735.  
  736. Special syntactic markers
  737. -------------------------
  738.  
  739.    GASP recognizes a few special markers: to delimit comments, to
  740. continue a statement on the next line, to separate symbols from other
  741. characters, and to copy text to the output literally.  (One other
  742. special marker, `\@', works only within macro definitions; *note
  743. Defining your own directives: Macros..)
  744.  
  745.    The trailing part of any GASP source line may be a "comment".  A
  746. comment begins with the first unquoted comment character (`!' by
  747. default), or an escaped or doubled comment character (`\!' or `!!' by
  748. default), and extends to the end of a line.  You can specify what
  749. comment character to use with the `-c' option (*note Command Line
  750. Options: Invoking GASP.).  The two kinds of comment markers lead to
  751. slightly different treatment:
  752.  
  753. `!'
  754.      A single, un-escaped comment character generates an assembly
  755.      comment in the GASP output.  GASP evaluates any preprocessor
  756.      variables (macro arguments, or variables defined with `.ASSIGNA' or
  757.      `.ASSIGNC') present.  For example, a macro that begins like this
  758.  
  759.                   .MACRO  SUM FROM=0, TO=9
  760.                   ! \FROM \TO
  761.  
  762.      issues as the first line of output a comment that records the
  763.      values you used to call the macro.
  764.  
  765. `\!'
  766. `!!'
  767.      Either an escaped comment character, or a double comment character,
  768.      marks a GASP source comment.  GASP does not copy such comments to
  769.      the assembly output.
  770.  
  771.    To *continue a statement* on the next line of the file, begin the
  772. second line with the character `+'.
  773.  
  774.    Occasionally you may want to prevent GASP from preprocessing some
  775. particular bit of text.  To *copy literally* from the GASP source to
  776. its output, place `\(' before the string to copy, and `)' at the end.
  777. For example, write `\(\!)' if you need the characters `\!' in your
  778. assembly output.
  779.  
  780.    To *separate a preprocessor variable* from text to appear
  781. immediately after its value, write a single quote (`'').  For example,
  782. `.SDATA "\P'1"' writes a string built by concatenating the value of `P'
  783. and the digit `1'.  (You cannot achieve this by writing just `\P1',
  784. since `P1' is itself a valid name for a preprocessor variable.)
  785.  
  786. 
  787. File: gasp.info,  Node: Constants,  Next: Symbols,  Prev: Markers,  Up: Syntax Details
  788.  
  789. String and numeric constants
  790. ----------------------------
  791.  
  792.    There are two ways of writing "string constants" in GASP: as literal
  793. text, and by numeric byte value.  Specify a string literal between
  794. double quotes (`"STR"').  Specify an individual numeric byte value as
  795. an absolute expression between angle brackets (`<EXPR>'.  Directives
  796. that output strings allow you to specify any number of either kind of
  797. value, in whatever order is convenient, and concatenate the result.
  798. (Alternate syntax mode introduces a number of alternative string
  799. notations; *note Alternate macro syntax: Alternate..)
  800.  
  801.    You can write "numeric constants" either in a specific base, or in
  802. whatever base is currently selected (either 10, or selected by the most
  803. recent `.RADIX').
  804.  
  805.    To write a number in a *specific base*, use the pattern `S'DDD': a
  806. base specifier character S, followed by a single quote followed by
  807. digits DDD.  The base specifier character matches those you can specify
  808. with `.RADIX': `B' for base 2, `Q' for base 8, `D' for base 10, and `H'
  809. for base 16.  (You can write this character in lower case if you
  810. prefer.)
  811.  
  812. 
  813. File: gasp.info,  Node: Symbols,  Next: Expressions,  Prev: Constants,  Up: Syntax Details
  814.  
  815. Symbols
  816. -------
  817.  
  818.    GASP recognizes symbol names that start with any alphabetic
  819. character, `_', or `$', and continue with any of the same characters or
  820. with digits.  Label names follow the same rules.
  821.  
  822. 
  823. File: gasp.info,  Node: Expressions,  Next: String Builtins,  Prev: Symbols,  Up: Syntax Details
  824.  
  825. Arithmetic expressions in GASP
  826. ------------------------------
  827.  
  828.    There are two kinds of expressions, depending on their result:
  829. "absolute" expressions, which resolve to a constant (that is, they do
  830. not involve any values unknown to GASP), and "relocatable" expressions,
  831. which must reduce to the form
  832.  
  833.      ADDSYM+CONST-SUBSYM
  834.  
  835. where ADDSYM and SUBSYM are assembly symbols of unknown value, and
  836. CONST is a constant.
  837.  
  838.    Arithmetic for GASP expressions follows very similar rules to C.
  839. You can use parentheses to change precedence; otherwise, arithmetic
  840. primitives have decreasing precedence in the order of the following
  841. list.
  842.  
  843.   1. Single-argument `+' (identity), `-' (arithmetic opposite), or `~'
  844.      (bitwise negation).  *The argument must be an absolute expression.*
  845.  
  846.   2. `*' (multiplication) and `/' (division).  *Both arguments must be
  847.      absolute expressions.*
  848.  
  849.   3. `+' (addition) and `-' (subtraction).  *At least one argument must
  850.      be absolute.*
  851.  
  852.   4. `&' (bitwise and).  *Both arguments must be absolute.*
  853.  
  854.   5. `|' (bitwise or) and `~' (bitwise exclusive or; `^' in C).  *Both
  855.      arguments must be absolute.*
  856.  
  857. 
  858. File: gasp.info,  Node: String Builtins,  Prev: Expressions,  Up: Syntax Details
  859.  
  860. String primitives
  861. -----------------
  862.  
  863.    You can use these primitives to manipulate strings (in the argument
  864. field of GASP statements):
  865.  
  866. `.LEN("STR")'
  867.      Calculate the length of string `"STR"', as an absolute expression.
  868.      For example, `.RES.B .LEN("sample")' reserves six bytes of memory.
  869.  
  870. `.INSTR("STRING", "SEG", IX)'
  871.      Search for the first occurrence of SEG after position IX of
  872.      STRING.  For example, `.INSTR("ABCDEFG", "CDE", 0)' evaluates to
  873.      the absolute result `2'.
  874.  
  875.      The result is `-1' if SEG does not occur in STRING after position
  876.      IX.
  877.  
  878. `.SUBSTR("STRING",START,LEN)'
  879.      The substring of STRING beginning at byte number START and
  880.      extending for LEN bytes.
  881.  
  882. 
  883. File: gasp.info,  Node: Alternate,  Prev: Syntax Details,  Up: Commands
  884.  
  885. Alternate macro syntax
  886. ======================
  887.  
  888.    If you specify `-a' or `--alternate' on the GASP command line, the
  889. preprocessor uses somewhat different syntax.  This syntax is
  890. reminiscent of the syntax of Phar Lap macro assembler, but it is *not*
  891. meant to be a full emulation of Phar Lap or similar assemblers.  In
  892. particular, GASP does not support directives such as `DB' and `IRP',
  893. even in alternate syntax mode.
  894.  
  895.    In particular, `-a' (or `--alternate') elicits these differences:
  896.  
  897. *Preprocessor directives*
  898.      You can use GASP preprocessor directives without a leading `.'
  899.      dot.  For example, you can write `SDATA' with the same effect as
  900.      `.SDATA'.
  901.  
  902. *LOCAL*
  903.      One additional directive, `LOCAL', is available.  *Note Defining
  904.      your own directives: Macros, for an explanation of how to use
  905.      `LOCAL'.
  906.  
  907. *String delimiters*
  908.      You can write strings delimited in these other ways besides
  909.      `"STRING"':
  910.  
  911.     `'STRING''
  912.           You can delimit strings with single-quote charaters.
  913.  
  914.     `<STRING>'
  915.           You can delimit strings with matching angle brackets.
  916.  
  917. *single-character string escape*
  918.      To include any single character literally in a string (even if the
  919.      character would otherwise have some special meaning), you can
  920.      prefix the character with `!' (an exclamation mark).  For example,
  921.      you can write `<4.3 !> 5.4!!>' to get the literal text `4.3 >
  922.      5.4!'.
  923.  
  924. *Expression results as strings*
  925.      You can write `%EXPR' to evaluate the expression EXPR and use the
  926.      result as a string.
  927.  
  928. 
  929. File: gasp.info,  Node: Index,  Prev: Commands,  Up: Top
  930.  
  931. Index
  932. *****
  933.  
  934. * Menu:
  935.  
  936. * +:                                    Markers.
  937. * -alternate:                           Invoking GASP.
  938. * -commentchar 'CHAR':                  Invoking GASP.
  939. * -copysource:                          Invoking GASP.
  940. * -debug:                               Invoking GASP.
  941. * -help:                                Invoking GASP.
  942. * -mri:                                 Invoking GASP.
  943. * -output OUTFILE:                      Invoking GASP.
  944. * -print:                               Invoking GASP.
  945. * -unreasonable:                        Invoking GASP.
  946. * -version:                             Invoking GASP.
  947. * -a:                                   Invoking GASP.
  948. * -c 'CHAR':                            Invoking GASP.
  949. * -d:                                   Invoking GASP.
  950. * -h:                                   Invoking GASP.
  951. * -M:                                   Invoking GASP.
  952. * -o OUTFILE:                           Invoking GASP.
  953. * -p:                                   Invoking GASP.
  954. * -s:                                   Invoking GASP.
  955. * -u:                                   Invoking GASP.
  956. * -v:                                   Invoking GASP.
  957. * .AELSE:                               Conditionals.
  958. * .AENDI:                               Conditionals.
  959. * .AENDR:                               Loops.
  960. * .AENDW:                               Loops.
  961. * .AENDW:                               Loops.
  962. * .AIF "STRA" CMP "STRB":               Conditionals.
  963. * .AIF EXPRA CMP EXPRB:                 Conditionals.
  964. * .ALIGN SIZE:                          Other Commands.
  965. * .ALTERNATE:                           Other Commands.
  966. * .AREPEAT AEXP:                        Loops.
  967. * .AWHILE EXPRA CMP EXPRB:              Loops.
  968. * .AWHILE STRA CMP STRB:                Loops.
  969. * .DATA EXPR, EXPR, ...:                Initialized.
  970. * .DATA.B EXPR, EXPR, ...:              Initialized.
  971. * .DATA.L EXPR, EXPR, ...:              Initialized.
  972. * .DATA.W EXPR, EXPR, ...:              Initialized.
  973. * .DATAB REPEAT, EXPR:                  Initialized.
  974. * .DATAB.B REPEAT, EXPR:                Initialized.
  975. * .DATAB.L REPEAT, EXPR:                Initialized.
  976. * .DATAB.W REPEAT, EXPR:                Initialized.
  977. * .END:                                 Other Commands.
  978. * .ENDM:                                Macros.
  979. * .EXITM:                               Macros.
  980. * .EXPORT NAME:                         Other Commands.
  981. * .FORM COL=COLS:                       Listings.
  982. * .FORM LIN=LN:                         Listings.
  983. * .FORM LIN=LN COL=COLS:                Listings.
  984. * .GLOBAL NAME:                         Other Commands.
  985. * .HEADING STRING:                      Listings.
  986. * .INCLUDE "STR":                       Other Commands.
  987. * .INSTR("STRING", "SEG", IX):          String Builtins.
  988. * .LEN("STR"):                          String Builtins.
  989. * .MACRO MACNAME:                       Macros.
  990. * .MACRO MACNAME MACARGS ...:           Macros.
  991. * .ORG:                                 Other Commands.
  992. * .PAGE:                                Listings.
  993. * .PRINT LIST:                          Listings.
  994. * .PRINT NOLIST:                        Listings.
  995. * .PROGRAM:                             Other Commands.
  996. * .RADIX S:                             Other Commands.
  997. * .RES COUNT:                           Uninitialized.
  998. * .RES.B COUNT:                         Uninitialized.
  999. * .RES.L COUNT:                         Uninitialized.
  1000. * .RES.W COUNT:                         Uninitialized.
  1001. * .SDATA "STR" ...:                     Initialized.
  1002. * .SDATAB REPEAT, "STR" ...:            Initialized.
  1003. * .SDATAC "STR" ...:                    Initialized.
  1004. * .SDATAZ "STR" ...:                    Initialized.
  1005. * .SRES COUNT:                          Uninitialized.
  1006. * .SRES.B COUNT:                        Uninitialized.
  1007. * .SRES.L COUNT:                        Uninitialized.
  1008. * .SRES.W COUNT:                        Uninitialized.
  1009. * .SRESC COUNT:                         Uninitialized.
  1010. * .SRESC.B COUNT:                       Uninitialized.
  1011. * .SRESC.L COUNT:                       Uninitialized.
  1012. * .SRESC.W COUNT:                       Uninitialized.
  1013. * .SRESZ COUNT:                         Uninitialized.
  1014. * .SRESZ.B COUNT:                       Uninitialized.
  1015. * .SRESZ.L COUNT:                       Uninitialized.
  1016. * .SRESZ.W COUNT:                       Uninitialized.
  1017. * .SUBSTR("STRING",START,LEN):          String Builtins.
  1018. * ! default comment char:               Invoking GASP.
  1019. * ; as comment char:                    Invoking GASP.
  1020. * INFILE ...:                           Invoking GASP.
  1021. * NAME .MACRO:                          Macros.
  1022. * NAME .MACRO ( MACARGS ... ):          Macros.
  1023. * PVAR .ASSIGN EXPR:                    Variables.
  1024. * PVAR .ASSIGNA AEXPR:                  Variables.
  1025. * PVAR .ASSIGNC "STR":                  Variables.
  1026. * PVAR .EQU EXPR:                       Variables.
  1027. * PVAR .REG (REGISTER):                 Variables.
  1028. * absolute expressions:                 Expressions.
  1029. * argument fields:                      Syntax Details.
  1030. * avoiding preprocessing:               Markers.
  1031. * bang, as comment:                     Invoking GASP.
  1032. * breaking out of loops:                Loops.
  1033. * comment character, changing:          Invoking GASP.
  1034. * comments:                             Markers.
  1035. * continuation character:               Markers.
  1036. * copying literally to output:          Markers.
  1037. * directive field:                      Syntax Details.
  1038. * EQ:                                   Conditionals.
  1039. * exclamation mark, as comment:         Invoking GASP.
  1040. * fields of GASP source line:           Syntax Details.
  1041. * GE:                                   Conditionals.
  1042. * GT:                                   Conditionals.
  1043. * label field:                          Syntax Details.
  1044. * LE:                                   Conditionals.
  1045. * literal copy to output:               Markers.
  1046. * LOCAL NAME [ , ... ]:                 Macros.
  1047. * loops, breaking out of:               Loops.
  1048. * LT:                                   Conditionals.
  1049. * macros, count executed:               Macros.
  1050. * NE:                                   Conditionals.
  1051. * number of macros executed:            Macros.
  1052. * preprocessing, avoiding:              Markers.
  1053. * relocatable expressions:              Expressions.
  1054. * semicolon, as comment:                Invoking GASP.
  1055. * shriek, as comment:                   Invoking GASP.
  1056. * symbol separator:                     Markers.
  1057. * symbols, separating from text:        Markers.
  1058. * text, separating from symbols:        Markers.
  1059. * whitespace:                           Syntax Details.
  1060. * \@:                                   Macros.
  1061.  
  1062.  
  1063. 
  1064. Tag Table:
  1065. Node: Top828
  1066. Node: Overview1276
  1067. Node: Invoking GASP2942
  1068. Node: Commands6678
  1069. Node: Conditionals7354
  1070. Node: Loops9646
  1071. Node: Variables11171
  1072. Node: Macros13566
  1073. Node: Data17528
  1074. Node: Initialized17976
  1075. Node: Uninitialized20255
  1076. Node: Listings21266
  1077. Node: Other Commands22462
  1078. Node: Syntax Details24214
  1079. Node: Markers25350
  1080. Node: Constants27598
  1081. Node: Symbols28800
  1082. Node: Expressions29096
  1083. Node: String Builtins30328
  1084. Node: Alternate31109
  1085. Node: Index32727
  1086. 
  1087. End Tag Table
  1088.